package com.jinly.ryder.flow.service.model;

import lombok.Data;

import java.util.List;
import java.util.Objects;

@Data
public class FlowRule {

    /**
     * 规则ID
     */
    private Integer id;

    /**
     * 规则名称
     */
    private String name;

    /**
     * 展示名称
     */
    private String showName;

    /**
     * 调用接口
     */
    private String invokeInterface;

    /**
     * 调用方法
     */
    private String invokeMethod;

    /**
     * 流程步骤
     */
    private List<FlowStep> stepList;

    public FlowStep getStep(String stepName) {
        if (stepList != null && stepName != null) {
            for (FlowStep flowStep : stepList) {
                if (Objects.equals(flowStep.getName(), stepName)) {
                    return flowStep;
                }
            }
        }
        return null;
    }

    public FlowStep getFirstStep() {
        if (stepList != null && stepList.size() > 0) {
            return stepList.get(0);
        }
        return null;
    }
}
